/** 引入action type */
import types from '../action/actionTypes'

/**
 * 首页缓存数据
 */
const homeData = {
    currentCity: '',
    cityList: [
        {label: '四川', value: 'sichuang'},
        {label: '陕西', value: 'sichuang'}
    ],
    userInfo: {}
}

/** 导出首页的所有reducer */
export default (preState = homeData, action) => {
    switch (action.type) {
        case types.GET_CITY_LIST:
            return {
                ...preState,
                cityList: action.list
            }
        case types.SAVE_USER_INFO:
            return {
                ...preState,
                userInfo: action.payload.userinfo
            }
        default:
            return preState
    }
}